Change in openvpn[master]: iservice: fix calculation of converted domains size
A message that is not in the archive (sent off-list or not yet received): gerrit.1763880426000.I16f9426e57f4802ba038ab51f5b70161464b9428@...2715...
Attention is currently required from: plaisthos.
Hello plaisthos,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email
to review the following change.
Change subject: iservice: fix calculation of converted domains size
......................................................................
iservice: fix calculation of converted domains size
To keep track of how much of the buffer is already used, the difference of the current position and the start of the buffer needs to be multiplied with the size of a character / glyph to bet the byte count, with which calculations are done further down below.
---
M src/openvpnserv/interactive.c
1 file changed, 11 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/90/1390/1
src/openvpnserv/interactive.c +11 -5
@@ -2181,8 +2181,11 @@ *comma ='\0' ; } -/* Ignore itf domains which match a pushed search domain */ size_t domain_len =wcslen (pos); +size_t domain_size = domain_len * one_glyph; +size_t converted_size = (pos - domains) * one_glyph; + +/* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain (search_domains, pos, domain_len)) {if (comma)
@@ -2199,11 +2202,14 @@ } } -/* Check for enough space to convert this domain */ - domain_len +=1 ;/* leading dot */ -size_t converted_size = pos - domains; -size_t domain_size = domain_len * one_glyph; +/* Add space for the leading dot */ + domain_len +=1 ; + domain_size +=1 ; + +/* Space for the terminating zeros */ size_t extra_size =2 * one_glyph; + +/* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) {/* Domain doesn't fit, bad luck if it's the first one */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428
Gerrit-Change-Number: 1390
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Attention is currently required from: d12fk, plaisthos.
cron2 has posted comments on this change by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email )
Change subject: iservice: fix calculation of converted domains size
......................................................................
Patch Set 1: Code-Review-1
(2 comments)
Patchset:
PS1:
I might be misreading this, but I think there is still an char/wchar mixup here
File src/openvpnserv/interactive.c:
http://gerrit.openvpn.net/c/openvpn/+/1390/comment/d13a1328_0f71fd2d?usp=email :
PS1, Line 2207: domain_size += 1;
shouldn't that be += one_glyph here? A wide-character dot will still take 2 bytes?
Maybe just move the size_t domain_size = domain_len * one_glyph down here so it will get the +1 right away? (Also it feels a bit more logical to do this after the ListContainsDomain() block, where it is used)
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428
Gerrit-Change-Number: 1390
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Sun, 23 Nov 2025 11:48:28 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Attention is currently required from: cron2, plaisthos.
d12fk has posted comments on this change by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email )
Change subject: iservice: fix calculation of converted domains size
......................................................................
Patch Set 1:
(1 comment)
File src/openvpnserv/interactive.c:
http://gerrit.openvpn.net/c/openvpn/+/1390/comment/4e90d085_1e83014a?usp=email :
PS1, Line 2207: domain_size += 1;
Quoted 1 line
shouldn't that be
+= one_glyphhere? A wide-character dot will still take 2 bytes? […]
Good catch! Moved it up there in prep for a following patch, adding one_glyph is the way to go.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428
Gerrit-Change-Number: 1390
Gerrit-PatchSet: 1
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Sun, 23 Nov 2025 19:47:51 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>
Attention is currently required from: cron2, plaisthos.
Hello cron2, plaisthos,
I'd like you to reexamine a change. Please visit
http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email
to look at the new patch set (#2).
The following approvals got outdated and were removed:
Code-Review-1 by cron2
Change subject: iservice: fix calculation of converted domains size
......................................................................
iservice: fix calculation of converted domains size
To keep track of how much of the buffer is already used, the difference of the current position and the start of the buffer needs to be multiplied with the size of a character / glyph to bet the byte count, with which calculations are done further down below.
---
M src/openvpnserv/interactive.c
1 file changed, 11 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/90/1390/2
src/openvpnserv/interactive.c +11 -5
@@ -2181,8 +2181,11 @@ *comma ='\0' ; } -/* Ignore itf domains which match a pushed search domain */ size_t domain_len =wcslen (pos); +size_t domain_size = domain_len * one_glyph; +size_t converted_size = (pos - domains) * one_glyph; + +/* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain (search_domains, pos, domain_len)) {if (comma)
@@ -2199,11 +2202,14 @@ } } -/* Check for enough space to convert this domain */ - domain_len +=1 ;/* leading dot */ -size_t converted_size = pos - domains; -size_t domain_size = domain_len * one_glyph; +/* Add space for the leading dot */ + domain_len +=1 ; + domain_size += one_glyph; + +/* Space for the terminating zeros */ size_t extra_size =2 * one_glyph; + +/* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) {/* Domain doesn't fit, bad luck if it's the first one */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428
Gerrit-Change-Number: 1390
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Attention is currently required from: d12fk, plaisthos.
cron2 has posted comments on this change by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email )
Change subject: iservice: fix calculation of converted domains size
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428
Gerrit-Change-Number: 1390
Gerrit-PatchSet: 2
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: d12fk <[email protected]...>
Gerrit-Comment-Date: Wed, 26 Nov 2025 10:34:12 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
PATCH v2 1/1 iservice: fix calculation of converted domains size
In reply to a message not in the archiveFrom: Heiko Hund <[email protected]...>
To keep track of how much of the buffer is already used, the difference of the current position and the start of the buffer needs to be multiplied with the size of a character / glyph to bet the byte count, with which calculations are done further down below.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1390
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1390
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpnserv/interactive.c +11 -5
@@ -2181,8 +2181,11 @@ *comma ='\0' ; } -/* Ignore itf domains which match a pushed search domain */ size_t domain_len =wcslen (pos); +size_t domain_size = domain_len * one_glyph; +size_t converted_size = (pos - domains) * one_glyph; + +/* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain (search_domains, pos, domain_len)) {if (comma)
@@ -2199,11 +2202,14 @@ } } -/* Check for enough space to convert this domain */ - domain_len +=1 ;/* leading dot */ -size_t converted_size = pos - domains; -size_t domain_size = domain_len * one_glyph; +/* Add space for the leading dot */ + domain_len +=1 ; + domain_size += one_glyph; + +/* Space for the terminating zeros */ size_t extra_size =2 * one_glyph; + +/* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) {/* Domain doesn't fit, bad luck if it's the first one */
[Openvpn-devel] [PATCH applied] Re: iservice: fix calculation of converted domains size
Stared long and hard at the code. Found lots of "this cannot work, really?" staring at it, that are all getting fixed in additional single-line patches later on - this is not a useful patch granularity, sending 8 patches to fix like 6 single-line bugs. Reviewing and testing something where the starting code is broken to no end and a single patch will not bring it into a correct state is not a good use of my time.
This said, this single-line change (plus a bit of movearound in preparation for the next patch) does what it says, calculate "converted_size" correctly, in bytes ("_len" in glyphs, "_size" = in bytes).
Your patch has been applied to the master branch.
commit ac6c9d65701ed6d41691497846a47cb4e72b2878
Author: Heiko Hund Date: Wed Nov 26 11:34:21 2025 +0100
iservice: fix calculation of converted domains size
Signed-off-by: Heiko Hund <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1390
Message-Id: <[email protected]...>
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#3) to the change originally created by d12fk. ( http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: iservice: fix calculation of converted domains size
......................................................................
iservice: fix calculation of converted domains size
To keep track of how much of the buffer is already used, the difference of the current position and the start of the buffer needs to be multiplied with the size of a character / glyph to bet the byte count, with which calculations are done further down below.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1390
Message-Id: <[email protected]...>
---
M src/openvpnserv/interactive.c
1 file changed, 11 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/90/1390/3
src/openvpnserv/interactive.c +11 -5
@@ -2181,8 +2181,11 @@ *comma ='\0' ; } -/* Ignore itf domains which match a pushed search domain */ size_t domain_len =wcslen (pos); +size_t domain_size = domain_len * one_glyph; +size_t converted_size = (pos - domains) * one_glyph; + +/* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain (search_domains, pos, domain_len)) {if (comma)
@@ -2199,11 +2202,14 @@ } } -/* Check for enough space to convert this domain */ - domain_len +=1 ;/* leading dot */ -size_t converted_size = pos - domains; -size_t domain_size = domain_len * one_glyph; +/* Add space for the leading dot */ + domain_len +=1 ; + domain_size += one_glyph; + +/* Space for the terminating zeros */ size_t extra_size =2 * one_glyph; + +/* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) {/* Domain doesn't fit, bad luck if it's the first one */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428
Gerrit-Change-Number: 1390
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email )
Change subject: iservice: fix calculation of converted domains size
......................................................................
iservice: fix calculation of converted domains size
To keep track of how much of the buffer is already used, the difference of the current position and the start of the buffer needs to be multiplied with the size of a character / glyph to bet the byte count, with which calculations are done further down below.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1390
Message-Id: <[email protected]...>
---
M src/openvpnserv/interactive.c
1 file changed, 11 insertions(+), 5 deletions(-)
src/openvpnserv/interactive.c +11 -5
@@ -2181,8 +2181,11 @@ *comma ='\0' ; } -/* Ignore itf domains which match a pushed search domain */ size_t domain_len =wcslen (pos); +size_t domain_size = domain_len * one_glyph; +size_t converted_size = (pos - domains) * one_glyph; + +/* Ignore itf domains which match a pushed search domain */ if (ListContainsDomain (search_domains, pos, domain_len)) {if (comma)
@@ -2199,11 +2202,14 @@ } } -/* Check for enough space to convert this domain */ - domain_len +=1 ;/* leading dot */ -size_t converted_size = pos - domains; -size_t domain_size = domain_len * one_glyph; +/* Add space for the leading dot */ + domain_len +=1 ; + domain_size += one_glyph; + +/* Space for the terminating zeros */ size_t extra_size =2 * one_glyph; + +/* Check for enough space to convert this domain */ if (converted_size + domain_size + extra_size > buf_size) {/* Domain doesn't fit, bad luck if it's the first one */
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1390?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I16f9426e57f4802ba038ab51f5b70161464b9428
Gerrit-Change-Number: 1390
Gerrit-PatchSet: 3
Gerrit-Owner: d12fk <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>